package cn.ssj.utils;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.List;
@SuppressWarnings("all")
public class pageBean<K,V> {
	
	private Integer startNum;//起始数
	private Integer pageSize=5;//分页大小,初始为5
	private Integer currentPageNum;//当前页
	private Integer prevPageNum;//上一页
	private Integer nextPageNum;//下一页
	private Integer total;//总页数
	private K entity;//实体
	private V entityExample;//实体扩展类
	private List<K> rows;
	
	public pageBean(Integer currentPageNum, Integer total, V entityExample) {
		this.currentPageNum = currentPageNum;
		this.total = total;
		this.entityExample = entityExample;
	}
	public pageBean(){
//		Type type=pageBean.class.getGenericSuperclass();
//		ParameterizedType parameterizedType=(ParameterizedType)type;
//		Class<K> clazz1=(Class<K>) parameterizedType.getActualTypeArguments()[0];
//		Class<V> clazz2=(Class<V>) parameterizedType.getActualTypeArguments()[1];
//		//Class<K> clazz1=(Class<K>)((ParameterizedType)pageBean.class.getGenericSuperclass()).getActualTypeArguments()[0];
//		//Class<V> clazz2=(Class<V>)((ParameterizedType)pageBean.class.getGenericSuperclass()).getActualTypeArguments()[1];
//		System.out.println(clazz1);
//		System.out.println(clazz2);
//		try {
//			this.entity=(K)clazz1.newInstance();
//			this.entityExample=(V)clazz2.newInstance();
//		} catch (InstantiationException e) {
//			e.printStackTrace();
//		} catch (IllegalAccessException e) {
//			e.printStackTrace();
//		}
	}
	public Integer getStartNum() {
		if(currentPageNum-1<=0){
			return 0;
		}
		return (currentPageNum-1)*pageSize;
	}
	public void setStartNum(Integer startNum) {
		this.startNum = startNum;
	}
	public Integer getPageSize() {
		return pageSize;
	}
	public void setPageSize(Integer pageSize) {
		this.pageSize = pageSize;
	}
	public Integer getCurrentPageNum() {
		return currentPageNum;
	}
	public void setCurrentPageNum(Integer currentPageNum) {
		this.currentPageNum = currentPageNum;
	}
	public Integer getPrevPageNum() {
		if(currentPageNum==1){
			return currentPageNum;
		}
		return currentPageNum-1;
	}
	public void setPrevPageNum(Integer prevPageNum) {
		this.prevPageNum = prevPageNum;
	}
	public Integer getNextPageNum() {
		if(currentPageNum==total){
			return total;
		}
		return currentPageNum+1;
	}
	public void setNextPageNum(Integer nextPageNum) {
		this.nextPageNum = nextPageNum;
	}
	
	public Integer getTotal() {
		return total;
	}
	public void setTotal(Integer total) {
		this.total = total;
	}
	public List<K> getRows() {
		return rows;
	}
	public void setRows(List<K> rows) {
		this.rows = rows;
	}
	public K getEntity() {
		return entity;
	}
	public void setEntity(K entity) {
		this.entity = entity;
	}
	public V getEntityExample() {
		return entityExample;
	}
	public void setEntityExample(V entityExample) {
		this.entityExample = entityExample;
	}
	
	
}
